<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Auth_model extends CI_Model {

	function register() {
	
		$data = array(
			'name'=> $_POST['name'],
			'mail'=> $_POST['mail'],
			'passwd'=> md5($_POST['passwd'])
			);
	
		return $this->db->insert('users',$data);
	
	
	
	}
	
	function check() {
	
		$select = $this->db->where('mail', $_POST['mail'])
						   ->where('passwd', md5($_POST['passwd']))
						   ->get('users');
						   
		return $select->num_rows();
	}
	
	function getUserData($mail) {
	
		$select = $this->db->select('id, name, mail, type')
						   ->where('mail',$mail)
						   ->limit(1)
						   ->get('users');
						  

		if($select->num_rows() > 0) return $select->row_array();
		else return false;
	
	}
	
}